package com.example.demo.kafkaDemo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class KafkaController {

    @Autowired
    KafkaTemplate kafkaTemplate;


    @GetMapping("/kafka/send_demo")
    public String sendDemo(String input) {
        ListenableFuture listenableFuture = kafkaTemplate.send("TOPICNAMEsxm", "66666");
        System.out.println();

        return "success";
    }

    @KafkaListener(id = "test-consumer-group", topics = "TOPICNAMEsxm")
    public void consume(String msg) {
        System.out.println("topics msg:---->" + msg);
    }
}
